<?php



/**
 * Skeleton subclass for representing a row from the 'bonus_goals_forms' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.empeval
 */
class EmpevalBonusGoalsForms extends EmpevalBaseBonusGoalsForms
{
	
	const STATUS_NEW = 0;	
	const STATUS_IN_EDITION_1 = 1;	
	const STATUS_TO_EMPLOYEE_ACCEPT_1 = 2;	
	const STATUS_TO_SUPERIOR_ACCEPT_1 = 3;	
	const STATUS_ACCEPTED_1 = 4;	
	const STATUS_IN_EDITION_2 = 5;	
	const STATUS_WAITING_FOR_SEND_TO_ACCEPT = 6;
	const STATUS_TO_USER_ACCEPT_2 = 7;
	const STATUS_TO_SUPERIOR_ACCEPT_2 = 8;
	const STATUS_TO_BE_ADDED_SELF_APPRAISAL = 9;
	const STATUS_ADDING_SELF_APPRAISAL = 10;
	const STATUS_TO_CALCULATE = 11;
	const STATUS_CALCULATING = 12;
	const STATUS_TO_USER_ACCEPT_3 = 13;
	const STATUS_REJECTED = 14;
	const STATUS_CLOSED = 15;
	const STATUS_HR_EDIT = 16;
	
	const LOW_GRADE_FORM = 0;
	const HIGH_GRADE_FORM = 1;
	
	public function canBeRemove($userId) {
		return ($userId == $this->getUserPositions()->getUserId() || in_array($userId, $this->getSuperiorsId()));
	}
	
	public function getSuperiorsId() {
		$parentPosition = $this->getUserPositions()->getPositions()->getPositionsRelatedByParentId();
		if (!$parentPosition instanceof EmpevalPositions || $parentPosition->getUserPositionss()->count() == 0)
			return array();
		$superiorsId = array();
		foreach ($parentPosition->getUserPositionss() as $up) {
			$superiorsId[] = $up->getUserId();
		}
		return $superiorsId;
	}
	
	public function isEmployee(EmpevalUsers $user) {
		return ($this->getUserPositions()->getUserId() == $user->getId());
	}
	
}
